package com.school_admin.mapper;

import com.school_admin.config.Result;
import com.school_admin.entity.Post;
import com.school_admin.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 
 * @since 2024-03-18
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {

    int getLikeCount(String uid);

    int getCollectionCount(String uid);

    @Select("SELECT COUNT(*) FROM sc_post WHERE uid = #{uid}")
    int getPublishCount(String uid);
    @MapKey("id")
    List<Map<String, Object>> getUserCollectionList(int start, int pageSize, String uid);
    Integer getCollectionCountByUid(String uid);
    @Select("SELECT * FROM `sc_post` WHERE uid = #{uid} AND deleted = 0 ORDER BY time DESC LIMIT #{start}, #{pageSize}")
    List<Post> getUserReleaseList(String uid, int start, int pageSize);
    @Select("SELECT count(*) FROM `sc_post` WHERE uid = #{uid}")
    int getUserReleaseCount(String uid);
}
